<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function(){
	$('#pid').change(function(){
		var level = parseInt($('#pid').find("option:selected").attr('level'))+1;
		$('#level').val(level);
	});
	
	$("form").submit(function(){
		var name = $("#name").val();
		var sort = $("#sort").val();
		var reg = new RegExp("^\\d+$");
		
		if(name == ''){
			alert("name required");
			return false;
		}
		
		if(!reg.test(sort)){
			alert("sort require number");
			return false;
		}
		if(parseInt($("#level").val())==3){
			var url =  $("#model").val() + "/" +$("#action").val();
			$("#url").val(url);
			if(url =="/"){
				alert("url required!");
				return false;
			}
		}
		
	});
});
</script>
<title>add menu</title>
</head>
<body>
<div class="main">
	<form action="__URL__/insert" method="post">
		<table>
			<tr>
				<td>parent:</td><td>
				<select name="pid" id="pid">
					<option value="0" level="0">top</option>
					<volist id="t" name="top">
						<option value="{$t.id}" level="{$t.level}">{$t.name}</option>
							<foreach name="t['sub']" item="m">
								<option value="{$m.id}" level="{$m.level}">&nbsp;&nbsp;&nbsp;{$m.name}</option>
							</foreach>
					</volist>
				</select></td>
			</tr>
			<tr><td>name:</td><td><input name="name" id="name" type="text"/></td></tr>
			<tr><td>model:</td><td><input name="model" id="model" type="text"/></td></tr>
			<tr><td>action:</td><td><input name="action" id="action" type="text"/></td></tr>
			<tr><td>sort:</td><td><input name="sort" id="sort" type="text" value="0"/></td></tr>
			<tr><td colspan="2"><input name="submit" type="submit" value="save"/></td></tr>
			<input name="url" id="url" type="hidden"/>
			<input type="hidden" name="level" id="level" value="1"/>
		</table>
	</form>
</div>
</body>
</html>